/*
 * AbstractBean.java
 *
 * Created on August 7, 2007, 12:01 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package tcc.domain;

import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 *
 * @author Diego
 */
public class AbstractBean implements Serializable{
    
    /** Creates a new instance of AbstractBean */
    public AbstractBean() {
    }
    
    @Override
    public String toString(){
        StringBuilder sb = new StringBuilder();
        for (Method elem : this.getClass().getMethods()) {
            if(elem.getName().startsWith("get")){
                try {
                    sb.append(elem.getName().substring(3));
                    sb.append(": ");
                    sb.append(elem.invoke(this));
                    sb.append('\n');
                } catch (Exception ex) {
                    throw new RuntimeException("Unable to call toString");
                }
                
            }
        }
        return sb.toString();
    }
    
}
